/*
 * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
 *
 * SPDX-License-Identifier: Apache-2.0
 */
#pragma once

#include <stdint.h>
#include "driver/rmt_encoder.h"

#define CUSTOM_LEADING_CODE_DURATION_0 300
#define CUSTOM_LEADING_CODE_DURATION_1 300
#define CUSTOM_DECODE_LEADING_MARGIN 100 // Tolerance for parsing RMT symbols into bit stream

#define CUSTOM_ENDING_CODE_DURATION_0 560

#define CUSTOM_PAYLOAD_ZERO_DURATION_0 280
#define CUSTOM_PAYLOAD_ZERO_DURATION_1 280
#define CUSTOM_PAYLOAD_ONE_DURATION_0 280
#define CUSTOM_PAYLOAD_ONE_DURATION_1 845
#define CUSTOM_DECODE_MARGIN 100         // Tolerance for parsing RMT symbols into bit stream


#ifdef __cplusplus
extern "C"
{
#endif
    typedef enum rmt_message_symbol_num_e
    {
        NEC_CLASS_NUM = 34,
        NEC_REPEAT_CLASS_NUM = 2,
        CUSTOM_CLASS_NUM = 42, // lead + BULLET_DATA_LEN * 8 + end
        FIX_BULLET_NUM = 10, // lead + 1byte + end.
    } rmt_message_symbol_num_t;

    typedef enum rmt_leading_type_e
    {
        NEC_LEADING_CLASS,
        CUSTOM_LEADING_CLASS,
    } rmt_leading_type_t;

bool nec_parse_frame(rmt_symbol_word_t *rmt_nec_symbols, uint8_t *command);
bool custom_parse_frame(rmt_symbol_word_t *rmt_nec_symbols, uint8_t *dummy_array);
bool nec_parse_frame_repeat(rmt_symbol_word_t *rmt_nec_symbols);
bool fix_bullet_parse_frame(rmt_symbol_word_t *rmt_nec_symbols, uint8_t *dummy_array);
#ifdef __cplusplus
}
#endif
